﻿using Microsoft.Xna.Framework;

namespace Fighter.Screens
{
    /// <summary>
    /// L'écran du menu principal
    /// </summary>
    class MainMenuScreen : MenuScreen
    {
        GraphicsDeviceManager graphics;
        Game game;
        #region Initialization


        /// <summary>
        /// Constructeur
        /// </summary>
        public MainMenuScreen(Game game, GraphicsDeviceManager graphics)
            : base("Fighter")
        {
            this.game = game;
            this.graphics = graphics;
            // Création des entrées pour le menu
            MenuEntry playGameMenuEntry = new MenuEntry("Jouer");
            MenuEntry optionsMenuEntry = new MenuEntry("Options");
            MenuEntry exitMenuEntry = new MenuEntry("Quitter");

            // Ajout des évènements
            playGameMenuEntry.Selected += PlayGameMenuEntrySelected;
            optionsMenuEntry.Selected += OptionsMenuEntrySelected;
            exitMenuEntry.Selected += OnCancel;

            // Ajout des entrées au menu
            MenuEntries.Add(playGameMenuEntry);
            MenuEntries.Add(optionsMenuEntry);
            MenuEntries.Add(exitMenuEntry);
        }


        #endregion

        #region Handle Input


        /// <summary>
        /// Evènement lorsque l'option "Jouer" a été choisie
        /// </summary>
        void PlayGameMenuEntrySelected(object sender, PlayerIndexEventArgs e)
        {
            LoadingScreen.Load(ScreenManager, true, e.PlayerIndex,
                               new GameplayScreen(this.game, graphics));
        }


        /// <summary>
        /// Evènement lorsque l'option "Options" a été choisie
        /// </summary>
        void OptionsMenuEntrySelected(object sender, PlayerIndexEventArgs e)
        {
            ScreenManager.AddScreen(new OptionsMenuScreen(), e.PlayerIndex);
        }


        /// <summary>
        /// Evènement lorsque l'option "Quitter" a été choisie
        /// </summary>
        protected override void OnCancel(PlayerIndex playerIndex)
        {
            ScreenManager.AddScreen(new QuitGameScreen(), playerIndex);
        }


        #endregion
    }
}
